package api

import (
	"github.com/gin-gonic/gin"
	"golang-websocket-chatroom/api/handler"
	"golang-websocket-chatroom/consts"
	"golang-websocket-chatroom/pkg"
)

func Router(g *gin.Engine) {
	api := g.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/login", handler.Login)
			user.GET("/list", handler.UserList)
		}

		chat := api.Group("/chat")
		{
			chat.Use(pkg.JWTAuth(consts.Jwt_SECRET_KEY))
			chat.GET("/chat", handler.Chat)
			chat.GET("/chatlist", handler.ChatList)
		}
		friend := api.Group("/friend")
		{
			friend.Use(pkg.JWTAuth(consts.Jwt_SECRET_KEY))
			friend.POST("/choose", handler.Choose)
		}
		room := api.Group("/room")
		{
			room.Use(pkg.JWTAuth(consts.Jwt_SECRET_KEY))
			room.POST("/room", handler.Room)
			room.GET("/room", handler.RoomList)
			room.POST("/addroom", handler.RoomAdd)
		}
	}
}
